var t = getApp();

Component({
    properties: {
        showCommentInput: {
            type: Boolean,
            value: !1
        },
        openImg: {
            type: Boolean,
            value: !1
        },
        options: {
            type: Object,
            value: function() {
                return {};
            }
        }
    },
    data: {
        fileList1: [],
        imgList: [],
        maincomment: "",
        prop_placeholder: "请留下你的精彩评论吧"
    },
    observers: {
        showCommentInput: function(t) {
            this.setData({
                maincomment: "",
                fileList1: [],
                imgList: []
            }), console.log(t, ";sdasdasd");
        }
    },
    methods: {
        onChange: function(t) {
            this.setData({
                maincomment: t.detail
            });
        },
        subMainBtn: function() {
            if (0 != this.data.maincomment.length || 0 != this.data.fileList1.length) {
                var t = {
                    text: this.data.maincomment,
                    imgs: this.data.fileList1
                };
                this.data.options && (t.options = this.data.options), this.triggerEvent("confirm", t), 
                this.setData({
                    showCommentInput: !1
                });
            } else wx.showToast({
                title: "不能发送空白信息",
                icon: "error"
            });
        },
        closedPopup: function() {
            this.setData({
                showCommentInput: !1
            });
        },
        updateImages: function() {},
        preview: function(t) {
            var e = t.currentTarget.dataset.src;
            wx.previewImage({
                current: this.data.fileList1[e],
                urls: this.data.fileList1
            });
        },
        delIntu_1: function(t) {
            var e = t.currentTarget.id;
            this.data.fileList1.splice(e, 1), this.setData({
                fileList1: this.data.fileList1
            }), this.updateImages();
        },
        onRead_1: function() {
            var t = this;
            wx.chooseImage({
                count: this.properties.max_count,
                sizeType: [ "original", "compressed" ],
                sourceType: [ "album", "camera" ],
                success: function(e) {
                    t.unload({
                        tempFilePaths: e.tempFilePaths
                    }, "1");
                }
            });
        },
        unload: function(e, i) {
            var a = t.getNetAddresss("upload.uploadPic"), s = this, n = e.i ? e.i : 0, o = e.success ? e.success : 0, l = e.fail ? e.fail : 0;
            wx.showLoading({
                title: "正在上传"
            }), wx.uploadFile({
                url: a,
                filePath: e.tempFilePaths[n],
                name: "file",
                formData: null,
                success: function(t) {
                    var e = JSON.parse(t.data);
                    "1" == i && (s.data.fileList1.push(e.data.img_url), s.setData({
                        fileList1: s.data.fileList1
                    }), s.updateImages());
                },
                fail: function(t) {
                    l++;
                },
                complete: function(t) {
                    wx.hideLoading(), ++n == e.tempFilePaths.length ? (console.log("执行完毕"), console.log("成功：" + o + " 失败：" + l)) : (e.i = n, 
                    e.success = o, e.fail = l, s.unload(e, i));
                }
            });
        }
    }
});